package com.lantosec.hmrp.modules.morality.controller;


import com.lantosec.hmrp.core.log.ControllerLog;
import com.lantosec.hmrp.core.log.LogType;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.lantosec.hmrp.core.kit.Result;
import com.lantosec.hmrp.modules.morality.entity.MoralityPlanLevel;
import com.lantosec.hmrp.modules.morality.service.IMoralityPlanLevelService;
import com.lantosec.hmrp.modules.morality.vo.MoralityPlanLevelVO;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.RestController;
import com.lantosec.hmrp.core.mvc.BaseController;

/**
 *
 * 考评方案等级 控制器
 *
 * @author AutoCode
 * @since 2020-06-23
 */
@Api(value = "考评方案等级控制器", tags = "考评方案等级控制器")
@RestController
@RequestMapping("/morality/plan/level")
@Log4j2
public class MoralityPlanLevelController extends BaseController {
    @Autowired
    private IMoralityPlanLevelService service;

    @GetMapping("get")
    @ApiOperation(value = "根据得分查询考评等级")
    public Result<List<MoralityPlanLevel>> get(@ApiParam(value = "考评方案ID", required = true) @RequestParam(name="moralityPlanId") Integer moralityPlanId){
        List<MoralityPlanLevel> moralityPlanLevel = service.list(new QueryWrapper<MoralityPlanLevel>().eq(MoralityPlanLevel.ColName.morality_plan_id.toString(),moralityPlanId));
        return Result.ok(moralityPlanLevel);
    }



    @DeleteMapping(value = "delete/{ids}")
    @ControllerLog(name = "逻辑删除考评方案等级", type = LogType.delete)
    @ApiOperation("逻辑删除")
    public Result<Void> delete(@ApiParam(value = "ID列表,用逗号分隔", required = true) @PathVariable(name="ids") String ids){
        if(StringUtils.isNotEmpty(ids)){
            service.removeByIds(Arrays.asList(ids.split(",")));
        }
        return Result.ok();
    }
}
